package com.fram.service.api.v1.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.fram.bean.api.browsing.request.BrowsingSearchRequest;
import com.fram.bean.api.browsing.response.BrowsingSearchResponse;
import com.fram.bean.sys.PageBean;
import com.fram.common.canstant.ErrCode;
import com.fram.common.exception.ProException;
import com.fram.common.exception.ProValiDataException;
import com.fram.common.util.base.BaseService;
import com.fram.service.api.v1.UserBrowsingService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * @作者： 陳曉鬆 @时间： 2020年5月28日 - 上午9:24:11 @description：->
 */
@Service("userBrowsingService")
public class UserBrowsingServiceImpl extends BaseService implements UserBrowsingService {

	@Override
	public PageInfo<BrowsingSearchResponse> list(PageBean<BrowsingSearchRequest> request) throws ProException {
		PageHelper.startPage(request.getPageNum(), request.getPageSize());
		List<BrowsingSearchResponse> list = browsingRecordsMapper.select(request.getParam());
		if (list == null || list.size() == 0) {
			throw new ProValiDataException(ErrCode.NO_DATA.getReturnCode(), ErrCode.NO_DATA.getReturnMsg());
		}
		return new PageInfo<>(list);
	}

}
